package com.ytjj.qmyx.admin.controller.supplyChain;


import com.alibaba.fastjson.JSON;
import com.ytjj.common.utils.HttpClientUtil;
import com.ytjj.qmyx.admin.config.SupplyApiConfig;
import com.ytjj.qmyx.admin.model.request.SalesStatisticalRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 商品统计管理
 */
@RestController
@RequestMapping("/productStatistical")
@Slf4j
public class ProductStatisticalController {

    @Autowired
    private SupplyApiConfig supplyApiConfig;

    @GetMapping("/getHead")
    public String getHead() {
        String s = HttpClientUtil.doGet(supplyApiConfig.getUrl() + "/productStatistical/getHead", null, supplyApiConfig.getHeadsMap());
        return s;
    }

    /**
     * 一级类目销售统计
     */
    @PostMapping("/statisticalByTopCategory")
    public String statisticalByTopCategory(@RequestBody SalesStatisticalRequest request){
        String s = HttpClientUtil.doPostJson(supplyApiConfig.getUrl() + "/productStatistical/statisticalByTopCategory", JSON.toJSONString(request), supplyApiConfig.getHeadsMap());
        return s;
    }
    /**
     * 商品销售统计
     */
    @PostMapping("/statisticalByProduct")
    public String statisticalByProduct(@RequestBody SalesStatisticalRequest request){
        String s = HttpClientUtil.doPostJson(supplyApiConfig.getUrl() + "/productStatistical/statisticalByProduct", JSON.toJSONString(request), supplyApiConfig.getHeadsMap());
        return s;
    }
}
